import { http } from '@/utils/http'
import type { PayDto } from '@/types/pay'

/**
 * 获取微信支付参数
 * @param data orderId 订单id
 */
export const getPayWxPayMiniPayAPI = (data: { orderId: string }) => {
  return http<WechatMiniprogram.RequestPaymentOption>({
    method: 'GET',
    url: '/pay/wxPay/miniPay',
    data,
  })
}

/**
 * 模拟支付-内测版
 * @param orderId
 */
export const getPayMockAPI = (orderId: string) => {
  return http<PayDto>({
    method: 'GET',
    url: `/app/pay/mock/${orderId}`,
  })
}

/**
 * 支付-微信支付
 * @param itemIds
 */
export const wxPayAPI = (itemIds: string[]) => {
  return http<PayDto>({
    method: 'POST',
    url: `/charge/order/appClient/`,
    data: itemIds, // 直接传递数组参数
  })
}

/**
 * 查询支付状态--微信支付
 * @param chId 病例id
 */
export const queryWxPayStatusAPI = (chId?: string) => {
  return http<PayDto>({
    method: 'POST',
    url: `/charge/order/queryPayStatus2/${chId}`,
  })
}


/**
 * 进行退款操作
 * @param itemIds
 */
export const backAPI = (itemIds: string[]) => {
  return http({
    method: 'POST',
    url: `/charge/backFee/app/back`,
    data: itemIds, // 直接传递数组参数
  });
}
